package com.orion.util;

import org.springframework.security.core.context.SecurityContextHolder;
import com.orion.config.CustomWebAuthenticationDetails;
import com.orion.domain.SysUser;

/**
 * @author Administrator
 * @date 2021/9/11
 */
public class SecurityHolderUtil {

    public static CustomWebAuthenticationDetails getUserDetail(){
        return (CustomWebAuthenticationDetails) SecurityContextHolder.getContext().getAuthentication().getDetails();
    }


    public static String getUserName(){
        return SecurityContextHolder.getContext().getAuthentication().getName();
    }

    public static SysUser getPrincipal(){
        return (SysUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    }
}
